package com.builder.improve;

/**
 * @author zhupanlin
 * @version 1.0
 * @description: TODO
 * @date 2024/4/14 10:15
 */
// 指挥者，动态指定制作流程
public class HouseDirector {
    
    HouseBuilder houseBuilder;
    
    // 构造器传入 houseBuilder
    public HouseDirector(HouseBuilder houseBuilder) {
        this.houseBuilder = houseBuilder;
    }
    
    // 通过setter 传入houseBuilder
    public void setHouseBuilder(HouseBuilder houseBuilder) {
        this.houseBuilder = houseBuilder;
    }
    
    // 如何建造房子，交给指挥者
    public House constructHouse(){
        houseBuilder.buildBasic();
        houseBuilder.buildWalls();
        houseBuilder.roofed();
        return houseBuilder.buildHouse();
    }
}
